<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" media="screen" href="../../global/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" media="screen" href="../../global/layui/css/layui.css">
</head>
<body>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
    <form class="form-horizontal" onsubmit="return false" id="form" enctype="multipart/form-data">
        <fieldset>
     <input type="hidden" id="userId" name="userId"/>
          <div class="form-group">
           <label class="col-md-2 control-label">昵称:</label>
           <div class="col-md-5">
            <input class="form-control" placeholder="昵称" type="text" name="username" id="username" data-bv-notempty="true" data-bv-notempty-message="昵称不能为空" />
           </div>
          </div>
          <div class="form-group">
           <label class="col-md-2 control-label">手机号码:</label>
           <div class="col-md-5">
            <input class="form-control" placeholder="手机号码" type="text" name="phone" id="phone" data-bv-notempty="true" data-bv-notempty-message="手机号码不能为空" />
           </div>
          </div>
           <div class="form-group">
                                  <label class="col-md-2 control-label">邀请人:</label>
                                  <div class="col-md-5">
                                   <input class="form-control" placeholder="邀请人" type="text" name="inviter" id="inviter"  />
                                  </div>
                                 </div>
 		<div class="form-group">
                                <label class="col-md-2 control-label">注册来源:</label>
                                <div class="col-md-5">
                                 <input class="form-control" placeholder="注册来源" type="text" name="registSource" id="registSource"  />
                                </div>
                               </div>
                               
         <div class="form-group">
                                <label class="col-md-2 control-label">注册时间:</label>
                                <div class="col-md-5">
                                 <input class="form-control" placeholder="注册时间" type="text" name="createTime" id="createTime"  />
                                </div>
                               </div>
          <div class="form-group">
                    <label class="col-md-2 control-label">头像:</label>
                    <div class="col-md-10">
                    <img id="icon" />
                    <input type="file" name="icon" id="icon" />
                    </div>
                    </div>
                    
          <div class="form-group">
                                       <label class="col-md-2 control-label">会员等级:</label>
                                       <div class="col-md-10" style="width: 120px">
                                       <select class="form-control input-sm" name="level" id="level">
                                       <option value="0" selected="selected">普通会员</option>
                                       <option value="1" >导师</option>
                                       <option value="2" >讲师</option>
                                       <option value="3" >经理</option> </select>
                                       </div>
                                       </div>
                                       
            <div class="form-group">
                               <label class="col-md-2 control-label">积分</label>
                               <div class="col-md-5">
                                <input class="form-control" placeholder="积分" type="text" name="integral" id="integral" disabled="disabled"/>
                               </div>
                              </div>
                              
            <div class="form-group">
                               <label class="col-md-2 control-label">零钱</label>
                               <div class="col-md-5">
                                <input class="form-control" placeholder="零钱" type="text" name="shoestringMoney" id="shoestringMoney" disabled="disabled"/>
                               </div>
                              </div>   
               <div class="form-group">
                               <label class="col-md-2 control-label">余额</label>
                               <div class="col-md-5">
                                <input class="form-control" placeholder="余额" type="text" name="account" id="account" disabled="disabled"/>
                               </div>
                              </div>                 
                                                         
                                       
                                       
           <div class="form-group">
                          <label class="col-md-2 control-label">是否开启:</label>
                          <div class="col-md-10" style="width: 120px">
                           <select class="form-control input-sm" name="openState" id="openState">
                           <option value="0" selected="selected">开启</option>
                           <option value="1" >未开启</option> </select>
                      </div>
                      </div>
                      
              <div class="form-group">
                               <label class="col-md-2 control-label">团队人数</label>
                               <div class="col-md-5">
                                <input class="form-control" placeholder="团队人数" type="text" name="teamNumber" id="teamNumber" disabled="disabled"/>
                               </div>
                              </div>           
                      
              <div class="form-group">
                               <label class="col-md-2 control-label">个人销量</label>
                               <div class="col-md-5">
                                <input class="form-control" placeholder="个人销量" type="text" name="personalSale" id="personalSale" disabled="disabled"/>
                               </div>
                              </div>       
          
                  <div class="form-group">
                               <label class="col-md-2 control-label">团队销量</label>
                               <div class="col-md-5">
                                <input class="form-control" placeholder="团队销量" type="text" name="teamSale" id="teamSale" disabled="disabled"/>
                               </div>
                              </div>               
                                              
            <div class="form-actions">
                <div class="row" align="center">
                    <div class="col-md-12">
                        <button class="btn btn-primary" onclick="location.href='clyjuserList.html'">返回</button>
                        <button class="btn btn-primary" type="submit" onclick="update()">
                            <i class="fa fa-save"></i> 保存
                        </button>
                    </div>
                </div>
            </div>
        </fieldset>

    </form>
</div>
<script type="text/javascript" src="../../global/js/libs/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="../../global/js/jq.js"></script>
<script type="text/javascript" src="../../global/js/plugin/bootstrapvalidator/bootstrapValidator.min.js"></script>
<script type="text/javascript" src="../../global/js/common.js"></script>
<script type="text/javascript" src="../../global/layui/layui.js"></script>
<script type="text/javascript" src="../../global/js/ajaxfileupload.js"></script>
<script type="text/javascript">
    layui.use(['layer', 'laydate'], function () {
        var layer = layui.layer;
        var laydate = layui.laydate;
        laydate.render({
            elem: '#birthday'
        });
    });
    //initRoles();
    initData();
    function initData() {
        var id = getUrlParam("id");
        if (id != "") {
            $.ajax({
                type: 'get',
                url: "/clyjUser/" + id,
                async: false,
                success: function (result) {
                    var data = result.data;
                     $("#userId").val(data.userId);
                     $("#nickName").val(data.nickName);
                     $("#phone").val(data.phone);
                     $("#inviter").val(data.inviter);
                     $("#registSource").val(data.registSource);
                     
                     var dateee = new Date(data.createTime).toJSON();
                     var date=new Date(+new Date(dateee) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '')
                     $("#createTime").val(date);
                     $("#icon").attr("src",data.photo);
                     $("#level").val(data.level);
                     $("#integral").val(data.integral);
                     $("#shoestringMoney").val(data.shoestringMoney);
                     $("#account").val(data.account);
                     $("#openState").val(data.openState);
                     $("#teamNumber").val(data.teamNumber);
                     $("#personalSale").val(data.personalSale);
                     $("#teamSale").val(data.teamSale);
                }
            });
           //initRoleDatas(id);
        }
    }
    $('#form').bootstrapValidator();

    function update() {
        // 表单验证
        var bootstrapValidator = $("#form").data('bootstrapValidator');
        bootstrapValidator.validate();
        if (!bootstrapValidator.isValid()) {
            return;
        }

        $("form").ajaxSubmit({
            type: 'post',
            url: '/clyjUser/updateUser',
            traditional: true,
            contentType: "application/json; charset=utf-8",
            //data: JSON.stringify(formdata),
            success: function (data) {
                layer.msg("修改成功", {shift: -1, time: 1000}, function () {
                    location.href = "clyjuserList.html";
                });
            }
        });
    }

</script>
</body>
</html>